<%@ page import="ztc.common.SiginBean" %>
<%@ page import="ztc.common.UserBean" %>
<%@ page import="ztc.service.DBTools" %>
<%--
  Created by IntelliJ IDEA.
  User: ztc
  Date: 16-4-6
  Time: 下午3:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>二维码签到系统</title>
  <link href="${pageContext.request.contextPath}/css/min.css" rel="stylesheet">
  <link href="${pageContext.request.contextPath}/css/login.css" rel="stylesheet">
  <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
  <script src="${pageContext.request.contextPath}/js/min.js"></script>
  <script src="${pageContext.request.contextPath}/js/my.js"></script>
  <link rel="shortcut icon" type="image/x-icon" href="${pageContext.request.contextPath}/img/favicon.ico" />
  <script type="text/javascript">
    myajax();
    lunxun();
    var msg='本次签到数据未保存！';
    window.onbeforeunload=function(){
      if(msg!='')
        return msg;
    }
    function makemsg(){
      msg='';
    }
  </script>
</head>
<%
  request.setCharacterEncoding("utf-8");
  SiginBean siginBean=null;
  if(request.getParameter("size")!=null){
    //UID
    Integer uid=((UserBean)session.getAttribute("userBean")).getId();
    //签到名称
    String name=request.getParameter("name");
    //二维码尺寸
    Integer size= Integer.valueOf(request.getParameter("size"));
    //二维码前景色
    String foreground=request.getParameter("foreground");
    //二维码背景色
    String background=request.getParameter("background");
    siginBean=new SiginBean(uid,name,size,foreground,background);
    session.setAttribute("siginBean",siginBean);
  }
  if(siginBean==null||new DBTools().isSiginNameRepeat(siginBean)){
%>
<jsp:forward page="issuance.jsp?msg=签到名称不能重复！" />
<%}%>
<body>
<div style="position:fixed;top: 20px; background:#ccc;height:50px;width:98%;left:1%;z-index:1;" id="topbar">
  <img src="/img/0.png" height="40px" style="position: relative;top: 10%;left: 5%;z-index: 2;">
  <img src="/img/135-round.png" height="40px" style="position: relative;top: 10%;">
  <img src="/img/435-round.png" height="40px" style="position: relative;top: 10%;">
  <label style="position: relative;top: 20%;">×××××××××× ××××××××××</label>
  <a href="/qr/issuance.jsp"><label style="position: relative;top: 20%;left:10%;">发布签到</label></a>
  <a href="/qr/showmem.jsp"><label style="position: relative;top: 20%;left:20%;">查看未保存布签到</label></a>
  <a href="/qr/showinf.jsp"><label style="position: relative;top: 20%;left:30%;">查看已保存布签到</label></a>
  <label style="position: relative;top: 20%;left:45%;" >
    <%=(session.getAttribute("userBean")==null?"<a href=\"/users/register.jsp\">注册</a>":"用户："+((UserBean)session.getAttribute("userBean")).getName())+"<a href=\"/users/logout\">注销</a> "%></label>
</div>
<div class="container-fluid" style="position: relative;top:40px;">
  <div class="row-fluid">
    <div class="span12">
      <div class="row-fluid">
          <div style="float:left;width:30%" align="center">
            <fieldset>
              <legend>已签到<label id="sum"></label>人</legend>
              <table class="table" id="table">
                <tr align="center"><td><B>学号</B></td><td><B>姓名</B></td><td><B>MAC</B></td></tr>
                <a href="/users/save?action=save"><button type="button" id="button" class="btn btn-primary btn-block btn-lg" onclick="makemsg()">结束签到</button></a>
              </table>
            </fieldset>
          </div>
          <div style="float:left;width:70%" align="center">
            <fieldset >
              <legend>扫描此二维码签到</legend>
              <img id="QRcode" src="${pageContext.request.contextPath}/qr/qrcode?flag=<%=Math.random()%>">
            </fieldset>
          </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>
